package com.lin.controller;
import com.lin.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * 请求参数的绑定
     * 1.方法的参数列表和客户端提交的name属性一致可自动封装
     * 2.参数也可以直接封装到javaBean的类中 List集合Map集合
 * 获取Servlet原生的API
 *  直接在方法的参数列表定义参数就可以
 */
@Controller
@RequestMapping("/param")
public class ParamController {
    @RequestMapping("/testParam")
    public String testParam(String username,String password){
        System.out.println("testParam执行了");
        System.out.println(username);
        System.out.println(password);
        return "success";
    }
    @RequestMapping("/testUser")
    public String testUser(User user){
        System.out.println("testUser执行了");
//        System.out.println(user.getList());
//        System.out.println(user.getMap());
        System.out.println(user);
        return "success";
    }
    /*获取Servlet原生的API*/
    @RequestMapping("/testServlet")
    public String testServlet(HttpServletRequest res, HttpServletResponse resp){
        HttpSession session = res.getSession();
        ServletContext servletContext = session.getServletContext();
        return "success";
    }
}
